from django.db import models
from ckeditor.fields import RichTextField


# Create your models here.
class Mytest(models.Model):
    name = models.CharField(max_length=10)
    age = models.PositiveIntegerField()


class Cke(models.Model):
    name = models.CharField(max_length=200)
    text = RichTextField(config_name='default')


from django.db import models
from django.contrib.auth import get_user_model

# Create your models here.

User = get_user_model()


class Book(models.Model):
    name = models.CharField(max_length=20)
    add_time = models.DateTimeField(auto_now=True)
    creator = models.ForeignKey(User, verbose_name='创建者', blank=True)


class City(models.Model):
    name = models.CharField(max_length=10, verbose_name='城市名称')

    class Meta:
        verbose_name = '城市名称'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name


class Zone(models.Model):
    name = models.CharField(max_length=10, verbose_name='小区')
    city = models.ForeignKey(City, verbose_name='城市')

    class Meta:
        verbose_name = '小区名称'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name


class Street(models.Model):
    name = models.CharField(max_length=20, verbose_name='街道名称')
    zone = models.ForeignKey(Zone, verbose_name='街道')

    class Meta:
        verbose_name = '街道名称'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name


class FileTestImage(models.Model):
    name = models.CharField(max_length=20,verbose_name='文件写入测试名称')
    img = models.ImageField(upload_to='test1',verbose_name='测试图片')

    class Meta:
        verbose_name = '图片写入测试'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name
